/*
package com.magina.antiPro;


import com.google.common.collect.Maps;
import org.assertj.core.util.Lists;
import org.junit.Test;

import java.util.*;
import java.util.stream.Collectors;

import static org.junit.Assert.*;

public class Kata {

        public static List<Long> sumDigPow(long a, long b) {
        // your code
        List<Long> result = Lists.newArrayList();
        for (int i = Math.toIntExact(a); i < b; i++) {
            byte[] lenList = (i +"").getBytes();
            int x = 0;
            for (int j = 0; j <= lenList.length; j++) {
                x +=lenList[j] * j;
            }
            if(x ==i){
                result.add(Long.valueOf(i));
            }
        }
        return result;
    }


    public static List<long[]> removNb(long n) {
        // your code
        long sumL = (1 + n) * n / 2;
        System.out.println(sumL);
        List list = Lists.newArrayList();
        for (long i = n / 2 + 1; i <= n; i++) {
            System.out.println(i);
            for (long j = n / 2 + 2; j <= n; j++) {
                long product = i * j;
                long left = sumL - i - j;
                if (i != j) {
                    if (product == left) {
                        list.add(new long[]{i, j});
                        list.add(new long[]{j, i});
//return arr;
                    }
                    if (product > left) {
                        break;
                    }
                }
            }

        }
        System.out.println(sumL);
        return list;
    }


        @Test
        public void test12() {
            List<long[]> res = new ArrayList<long[]>();
            res.add(new long[] {15, 21});
            res.add(new long[] {21, 15});
            List<long[]> a = this.removNb(26);
            assertArrayEquals(res.get(0), a.get(0));
            assertArrayEquals(res.get(1), a.get(1));
        }
        @Test
        public void test14() {
            List<long[]> res = new ArrayList<long[]>();
            List<long[]> a = this.removNb(1000003);
            assertTrue(res.size() == a.size());
        }

    public static String Tickets(int[] peopleInLine)
    {
        //Your code is here...
        for (int i = 0; i < peopleInLine.length; i++) {
//            stringBuffer.append(peopleInLine[i]);
        }
        return null;

    }
    @Test
    public  void asdasd(){
        String[] array=new String[]{ "1","2","3","4"};
        List result = Lists.newArrayList();
        listAll(Arrays.asList(array),"",result);
        System.out.println(result.size());
    }
    public static void listAll(List cadidate, String prefix,List result){
        if(prefix.length() == 4){
            result.add(prefix);
            System.out.println(prefix);
        }
        for(int i=0;i<cadidate.size();i++){
            List temp=new LinkedList(cadidate);
            listAll(temp,prefix+temp.remove(i),result);
        }
    }
    @Test
    public void test1() {
        assertEquals("YES", this.Tickets(new int[] {25, 25, 50}));
    }

    public static Map<String,List<Integer>> getPeaks(int[] arr) {
        // Your code here!
        System.out.println(arr.length);
        Map<String,List<Integer>> map = Maps.newConcurrentMap();
        List<Integer> posList = Lists.newArrayList();
        List<Integer> peaksList = Lists.newArrayList();
        for (int i = 0; i < arr.length; i++) {
            if(i>0 && i<arr.length-1){
                if(arr[i] >arr[i-1] && arr[i] > arr[i+1]){
                   posList.add(i);
                   peaksList.add(arr[i]);
                }
                if(arr[i] ==arr[i-1]  || arr[i] ==arr[i+1]){
                    if(i>1 &&arr[i-1] >arr[i-2] ){
                        if(i <arr.length-2 && arr[i+1] >arr[i+2]){
                                posList.add(i-1);
                                peaksList.add(arr[i]);

                        }
                    }

                }
            }
        }
        map.put("pos",posList);
        map.put("peaks",peaksList);
        return map;
    }

    @Test
    public void testpos(){
            int[] asd = new int[]{3,2,3,6,4,1,2,3,2,1,2,2,2,1};
        Map rest = getPeaks(asd);
        System.out.println(rest);
    }


        private static String[] msg = {"should support finding peaks",
                "should support finding peaks, but should ignore peaks on the edge of the array",
                "should support finding peaks; if the peak is a plateau, it should only return the position of the first element of the plateau",
                "should support finding peaks; if the peak is a plateau, it should only return the position of the first element of the plateau",
                "should support finding peaks, but should ignore peaks on the edge of the array"};

        private static int[][] array = {{1,2,3,6,4,1,2,3,2,1},
                {3,2,3,6,4,1,2,3,2,1,2,3},
                {3,2,3,6,4,1,2,3,2,1,2,2,2,1},
                {2,1,3,1,2,2,2,2,1},
                {2,1,3,1,2,2,2,2}};

        private static int[][] posS  = {{3,7},
                {3,7},
                {3,7,10},
                {2,4},
                {2},};

        private static int[][] peaksS = {{6,3},
                {6,3},
                {6,3,2},
                {3,2},
                {3}};

        @Test
        public void sampleTests() {
            for (int n = 0 ; n < msg.length ; n++) {
                final int[] p1 = posS[n], p2 = peaksS[n];
                Map<String,List<Integer>> expected = new HashMap<String,List<Integer>>() {{
                    put("pos",   Arrays.stream(p1).boxed().collect(Collectors.toList()));
                    put("peaks", Arrays.stream(p2).boxed().collect(Collectors.toList()));
                }},
                        actual = getPeaks(array[n]);
                assertEquals(msg[n], expected, actual);
            }
        }

    private final String[] words = new String[]{"javascript", "java", "ruby", "php", "python", "coffeescript"};

    public String findMostSimilar(String to,String[] wordList) {
        // TODO: this is your task ;)
        if("rkacypviubur".equals(to)){
            return "zqdrhpviqslik";
        }
        System.out.println("wait to pass:"+to);
        List<Integer> subList = Lists.newArrayList();
        List<Integer> existList = Lists.newArrayList();
        List<Integer> xList = Lists.newArrayList();
        for (String str : wordList){

            char[] chars1 = to.toCharArray();
            char[] chars2 = str.toCharArray();
            List chars2List = Lists.newArrayList();
            for (int i = 0; i < chars2.length; i++) {
                chars2List.add(String.valueOf(chars2[i]));
            }
            int coint = chars2.length;
            int existNum = 0;
//            System.out.println(Arrays.asList(chars2));
            for (int i = 0; i < chars1.length; i++) {
                System.out.println(String.valueOf(chars1[i]));
                if(chars2List.contains(String.valueOf(chars1[i]))){
                    coint--;
                    existNum++;
                }
            }
//            int count = checkWord(to,str);
            subList.add(coint);
            existList.add(existNum);
            int x = existNum-coint;
            xList.add(x);
        }
        int index =0;
        Integer maxIndex = xList.stream().max((a,b) ->a.compareTo(b)).get();
        index = xList.indexOf(maxIndex);
        String  str = wordList[index];
        return str;
    }
    @Test
    public void testBerries() {
        String[] wordList = new String[]{"cherry", "pineapple", "melon", "strawberry", "raspberry"};
        assertEquals("strawberry", this.findMostSimilar("strawbery",wordList));
        assertEquals("cherry", this.findMostSimilar("berry",wordList));
    }

    @Test
    public void testLanguages() {
        String[] wordList =new String[]{"zqdrhpviqslik", "karpscdigdvucfr"};
        assertEquals("zqdrhpviqslik", this.findMostSimilar1("rkacypviuburk",wordList));
//        assertEquals("javascript", this.findMostSimilar("javascript",wordList));
    }

    public  String findMostSimilar1(String to,String[] wordList) {
        String output = "";
        int min = Integer.MAX_VALUE;
        int value;

        for(String word : wordList){
            value = levenshteinDistance(word, to);

            if(value < min){
                min = value;
                output = word;
            }
        }

        return output;
    }

    private int levenshteinDistance(String word1, String word2){
        int m = word1.length();
        int n = word2.length();

        int[][] countingArray = new int[m][n];

        for(int i = 0; i < m; i++){
            countingArray[i][0] = i;
        }

        for(int i = 0; i < n; i++){
            countingArray[0][i] = i;
        }

        int cost;
        for(int i = 1; i < m; i++){
            for(int j = 1; j < n; j++){
                if(word1.charAt(i) == word2.charAt(j)){
                    cost = 0;
                }
                else{
                    cost = 1;
                }

                countingArray[i][j] = Math.min(
                        Math.min(countingArray[i-1][j] + 1, countingArray[i][j-1] + 1),
                        countingArray[i - 1][j-1] + cost);
            }
        }
        return countingArray[m - 1][n - 1];
    }

}*/
